/**
 * Created by yhg97p on 2016/9/27.
 */
define(['app', 'filters/filters'], function(app) {
	app.register.controller('myCourse', function($scope, $http, $state, $sce, $stateParams, $rootScope) {
		// $rootScope.header1=0;
		$scope.blank = false;
		$scope.systems = navigator.platform;
        $scope.loading_show = true;
        $scope.tipModal = {
			isShow: false,
			title: '温馨提示',
			data: {},
			confirm: function() {
				this.hide()
			},
			cancel: function() {
				this.hide()
			},
			hide: function() {
				this.isShow = false;
			},
			show: function() {
				this.isShow = true;
			}
		};
	    if($rootScope.num==0){
			$scope.tipModal.show();
			$rootScope.num=1;
		}
		
		
		$scope.gostudy = function() {
				var url = $state.href('app.compProfession');
				window.location.href = url;				
			}
		// $rootScope.goComp = function() {
		// 		var url = $state.href('app.compProfession');
		// 		window.location.href = url;
		// 	}

		$scope.load = {
			_getCourseinfo: function() { //专业类别和专业
				$http({
					url: app._baseUrl + '/My/MyStudy/learnCurriculumList',
					method: 'POST',
					headers: {
						'Content-Type': 'application/x-www-form-urlencoded'
					}
				}).success(function(res) {

					if(res.success && res.data) {
                        $scope.loading_show = false;
						$scope.items = res.data;
						if($scope.items.length == 0) {
							$scope.blank = true;
						} else {
							$scope.equaltime = true;
							$scope.blank = false;
							angular.forEach($scope.items, function(v, k) {
									v.year = v.learn_time.substr(0, 4);
									v.five = v.learn_time.substring(5, 6);
									v.day = v.learn_time.substring(8, 10);
									if(v.five == 0) {
										v.month = v.learn_time.substring(6, 7);
									} else {
										v.month = v.learn_time.substring(5, 7);
									}
								}

							)
						}
					} else {
                        $scope.loading_show = false;
						$scope.blank = true;
					}

				});

			},
			init: function() {
				$scope.Courseinfo = [];
				this._getCourseinfo && this._getCourseinfo();
			}
		};
		$scope.load.init && $scope.load.init();

	})
})